{include file="header"}
<div class="x-nav">
           <span class="layui-breadcrumb">
            <a href="">{:lang("system")}</a>
            <a>
              <cite>{:lang("set")}</cite></a>
          </span>

</div>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            {volist name="lists" id="item"}
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red"></span>{:lang($item['set_desc'])}
                </label>
                {if $item.field_type eq 3}
                <div class="layui-input-block">

                    <div id="editor">
                        {php}
                        echo html_entity_decode($item['set_value']);
                        {/php}
                    </div>
                </div>

                {else}
                <div class="layui-input-block">
                    {if $item.field_type eq 2}
                    <textarea name="{$item.set_field}" placeholder="{:lang('please.enter')}" class="layui-textarea">{$item.set_value}</textarea>
                    {else}
                    <input type="text" name="{$item.set_field}" placeholder="{:lang('please.enter')}" autocomplete="off" class="layui-input" value="{$item.set_value}">
                    {/if}

                </div>
                {/if}


            </div>
            {/volist}
            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    {:lang('edit')}
                </button>
            </div>
        </form>
    </div>
</div>
{include file="footer"}
<script src="/static/wangEditor-4.6.15/wangEditor.min.js"></script>
<script src="/static/i18next/i18next.min.js"></script>
<script>
    const E = window.wangEditor
    const editor = new E('#editor')
    editor.config.menus = [
        'head',
        'bold',
        'fontSize',
        'fontName',
        'italic',
        'underline',
        'strikeThrough',
        'indent',
        'lineHeight',
        'foreColor',
        'backColor',
        'link',
        'list',
        'todo',
        'justify',
        'quote',
        'emoticon',
        'table',
        'code',
        'splitLine',
        'undo',
        'redo',
    ]
    editor.config.lang = 'en'
    editor.i18next = window.i18next

    editor.create()
    layui.use(['form', 'layer'], function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data) {
            data.field.payment_methods = editor.txt.html()
            request("POST",'{:url("set/index")}',data.field,function (res,msg) {
                //发异步，把数据提交给php

                layer.alert(msg, {icon: 6}, function() {
                    layer.closeAll();
                });
            })

            return false;
        });

    });
</script>